function proj_visuals           

plot_task3(0);
plot_task3(1);
plot_task4;

end

function plot_task3(isSinglePlot)

    %M/M/3
    figure(1);
    data = load('task3/system_fcfs_mm3');
    databar = data(:, 1);
    conf = data(:, 3) - data(:, 2);

    plot(0.1:0.1:0.9, databar, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
    errorbar(0.1:0.1:0.9, databar, conf);

    data = load('task3/system_sjf_mm3');
    databar = data(:, 1);
    conf = data(:, 3) - data(:, 2);

    plot(0.1:0.1:0.9, databar, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
    errorbar(0.1:0.1:0.9, databar, conf);

if (~isSinglePlot)
    hTitle = title('Average system time vs \rho');
    hXLabel = xlabel('\rho');
    hYLabel = ylabel('Average system time (sec)');
    hLegend = legend({'FCFS M/M/3', 'CI', 'SJF M/M/3', 'CI'}, 'Location', 'Best');

    set(gca,'FontName','Helvetica')

    set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
    set([hLegend, gca], 'FontSize', 10);
    set([hXLabel, hYLabel], 'FontSize', 12)
    set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
    grid on
    set(gca, ...
            'Box'         , 'off'     , ...
            'TickDir'     , 'out'     , ...
            'TickLength'  , [.02 .02] , ...
            'XMinorTick'  , 'on'      , ...
            'YMinorTick'  , 'on'      , ...
            'YGrid'       , 'on'      , ...
            'XColor'      , [.3 .3 .3], ...
            'YColor'      , [.3 .3 .3], ...
            'LineWidth'   , 1         );
    axis fill
    set(gcf, 'PaperPositionMode', 'auto');
    print('-depsc2', 'task3/system_mm3.eps');
    close;
    else
    hold on;
    end

    %M/G/3
    figure(1);
    data = load('task3/system_fcfs_mg3');
    databar = data(:, 1);
    conf = data(:, 3) - data(:, 2);

if (~isSinglePlot)
    plot(0.1:0.1:0.9, databar, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
    errorbar(0.1:0.1:0.9, databar, conf);
    else 
    plot(0.1:0.1:0.9, databar, 'bs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
    errorbar(0.1:0.1:0.9, databar, conf);
    end

    data = load('task3/system_sjf_mg3');
    databar = data(:, 1);
    conf = data(:, 3) - data(:, 2);

if (~isSinglePlot)
    plot(0.1:0.1:0.9, databar, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
    errorbar(0.1:0.1:0.9, databar, conf);
    else
    plot(0.1:0.1:0.9, databar, 'ks-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
    errorbar(0.1:0.1:0.9, databar, conf);
    end

if (~isSinglePlot)
    hTitle = title('Average system time vs \rho');
    hXLabel = xlabel('\rho');
    hYLabel = ylabel('Average system time(sec)');
    hLegend = legend({'FCFS M/G/3', 'CI', 'SJF M/G/3', 'CI'}, 'Location', 'Best');

    set(gca,'FontName','Helvetica')

    set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
    set([hLegend, gca], 'FontSize', 10);
    set([hXLabel, hYLabel], 'FontSize', 12)
    set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
    grid on
    set(gca, ...
            'Box'         , 'off'     , ...
            'TickDir'     , 'out'     , ...
            'TickLength'  , [.02 .02] , ...
            'XMinorTick'  , 'on'      , ...
            'YMinorTick'  , 'on'      , ...
            'YGrid'       , 'on'      , ...
            'XColor'      , [.3 .3 .3], ...
            'YColor'      , [.3 .3 .3], ...
            'LineWidth'   , 1         );
    axis fill
    set(gcf, 'PaperPositionMode', 'auto');

    print('-depsc2', 'task3/system_mg3.eps');
    else
    hTitle = title('Average system time vs \rho');
    hXLabel = xlabel('\rho');
    hYLabel = ylabel('Average system time(sec)');
    hLegend = legend({'FCFS M/M/3', 'CI', 'SJF M/M/3', 'CI','FCFS M/G/3', 'CI', 'SJF M/G/3', 'CI'}, 'Location', 'Best');

    set(gca,'FontName','Helvetica')

    set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
    set([hLegend, gca], 'FontSize', 10);
    set([hXLabel, hYLabel], 'FontSize', 12)
    set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
    grid on
    set(gca, ...
            'Box'         , 'off'     , ...
            'TickDir'     , 'out'     , ...
            'TickLength'  , [.02 .02] , ...
            'XMinorTick'  , 'on'      , ...
            'YMinorTick'  , 'on'      , ...
            'YGrid'       , 'on'      , ...
            'XColor'      , [.3 .3 .3], ...
            'YColor'      , [.3 .3 .3], ...
            'LineWidth'   , 1         );
    axis fill
    set(gcf, 'PaperPositionMode', 'auto');    
    print('-depsc2', 'task3/system.eps');    
    end
    close;

    end

    function plot_task4
    data1 = load('task4/output_fcfs_mm1');
    data2 = load('task4/output_sjf_mm1');
    data3 = load('task4/output_fcfs_mg1');
    data4 = load('task4/output_sjf_mg1');
    
    [~, I] = sort(data1(:, 1));
    data1 = data1(I, :);
    slowdown1 = reshape(data1(:, 2), 1000, 100);
    plot(mean(slowdown1), 'bs-', 'LineWidth', 2, 'MarkerSize', 1);
    hold on;
    [~, I] = sort(data2(:, 1));
    data2 = data2(I, :);
    slowdown2 = reshape(data2(:, 2), 1000, 100);
    plot(mean(slowdown2), 'rs-', 'LineWidth', 2, 'MarkerSize', 1);
    hTitle = title('Slowdown vs Percentile of service time distribution');
    hXLabel = xlabel('Perentile of service time distribution');
    hYLabel = ylabel('Slowdown');
    hLegend = legend({'FCFS M/M/1', 'SJF M/M/1'}, 'Location', 'Best');

    set(gca,'FontName','Helvetica')

    set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
    set([hLegend, gca], 'FontSize', 10);
    set([hXLabel, hYLabel], 'FontSize', 12)
    set(hTitle,'FontSize', 13, 'FontWeight', 'bold');
    grid on
    set(gca, ...
            'Box'         , 'off'     , ...
            'TickDir'     , 'out'     , ...
            'TickLength'  , [.02 .02] , ...
            'XMinorTick'  , 'on'      , ...
            'YMinorTick'  , 'on'      , ...
            'YGrid'       , 'on'      , ...
            'XColor'      , [.3 .3 .3], ...
            'YColor'      , [.3 .3 .3], ...
            'LineWidth'   , 1         );
    axis fill
    set(gcf, 'PaperPositionMode', 'auto');
    print('-depsc2', 'task4/slowdown_mm1.eps');
    close;



    [~, I] = sort(data3(:, 1));
    data3 = data3(I, :);
    slowdown3 = reshape(data3(:, 2), 1000, 100);
    plot(mean(slowdown3), 'bs-', 'LineWidth', 2, 'MarkerSize', 1);
    hold on;
    [~, I] = sort(data4(:, 1));
    data4 = data4(I, :);
    slowdown4 = reshape(data4(:, 2), 1000, 100);
    plot(mean(slowdown4), 'rs-', 'LineWidth', 2, 'MarkerSize', 1);

    hTitle = title('Slowdown vs Percentile of service time distribution');
    hXLabel = xlabel('Perentile of service time distribution');
    hYLabel = ylabel('Slowdown');
    hLegend = legend({'FCFS M/G/1', 'SJF M/G/1'}, 'Location', 'Best');

    set(gca,'FontName','Helvetica')

    set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
    set([hLegend, gca], 'FontSize', 10);
    set([hXLabel, hYLabel], 'FontSize', 12)
    set(hTitle,'FontSize', 12, 'FontWeight', 'bold');
    grid on
    set(gca, ...
            'Box'         , 'off'     , ...
            'TickDir'     , 'out'     , ...
            'TickLength'  , [.02 .02] , ...
            'XMinorTick'  , 'on'      , ...
            'YMinorTick'  , 'on'      , ...
            'YGrid'       , 'on'      , ...
            'XColor'      , [.3 .3 .3], ...
            'YColor'      , [.3 .3 .3], ...
            'LineWidth'   , 1         );
    axis fill
    set(gcf, 'PaperPositionMode', 'auto');
    print('-depsc2', 'task4/slowdown_mg1.eps');
    close;
end
